package com.xbq.exceleditor.db.entity

import android.os.Parcel
import android.os.Parcelable
import androidx.annotation.Keep
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.xbq.xbqsdk.util.format.FormatUtils

/**
 * Author: liaohaiping
 * Time: 2020-04-24
 * Description:
 */
@Entity(
    tableName = "t_excelinfo",
)
@Keep
class ExcelBean() :  Parcelable {
    @ColumnInfo
    @PrimaryKey(autoGenerate = true)
    var id: Int = 0

    @ColumnInfo
    var title: String = ""

    @ColumnInfo
    var path: String = ""

    @ColumnInfo
    var xlsxPath:String = ""

    @ColumnInfo
    var createTime: Long = System.currentTimeMillis()

    constructor(parcel: Parcel) : this() {
        id = parcel.readInt()
        title = parcel.readString()!!
        path = parcel.readString()!!
        createTime = parcel.readLong()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeString(title)
        parcel.writeString(path)
        parcel.writeLong(createTime)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<ExcelBean> {
        override fun createFromParcel(parcel: Parcel): ExcelBean {
            return ExcelBean(parcel)
        }

        override fun newArray(size: Int): Array<ExcelBean?> {
            return arrayOfNulls(size)
        }
    }


    fun createTimeStr() = FormatUtils.formatYMDHM(createTime)
}